<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">{{message}}</div>

    <script>
        // 生命周期函数就是vue实例在某个时间点会自动执行的函数
        var vm = new Vue({
            data: {
                message: "hello"
            },
            beforeCreate: function () {
                console.log("beforeCreate:" + this.message);
            },
            created: function () {
                console.log("created:" + this.message);
            },
            beforeMount: function () {
                console.log(this.$el);
                console.log("beforeMount");
            },
            mounted: function () {
                console.log(this.$el);
                console.log("mounted");
                this.$nextTick(function () {
                    console.log(1)
                    // Code that will run only after the
                    // entire view has been rendered
                });
                console.log(document.getElementById('app').innerText)
            },
            beforeDestroy: function () {
                console.log("beforeDestroy");
            },
            destroyed: function () {
                console.log("destroyed");
            },
            beforeUpdate: function () {
                console.log("beforeUpdate");
            },
            updated: function () {
                console.log("updated");
            }
        }).$mount('#app')
    </script>
</body>
</html>
